module.exports = function ($scope, $state, $stateParams,$resource,$modal,FileUploader,toaster, iteminfo, flag, type, $modalInstance, array) {
    console.log(iteminfo);
    console.log(array);
    console.log(flag, type);
    var para = {};
    var paras = {};
    var url = '';
    var url1 = '';
    $scope.info = {
        'title' : ''
    };
    $scope.array = array;
    var reason = [];
    var reasonStr = '';
    var level = '';
    if (type == '1') {
      level = '3';
    } else if (type == '2') {
      level = '4';
    }
    for (var i = 0; i < $scope.array.length; i++) {
        if ($scope.array[i].reject != undefined) {
            reason.push($scope.array[i].reject);
        }
        console.log(reason);
        reasonStr = reason.join(',');
        console.log(reasonStr);
        $scope.info.title = reasonStr;
    }
    $scope.ok = function(){
      if (type == '1' && flag == 'pass'){
        url = '/api/ac/ggc/reviewCompanyProjectService/updateLeaderUp';
        para = {
          'project_code' : iteminfo.project_code,
          'leader_message' : $scope.info.title
        }
        url1 = '/api/ac/ggc/reviewCompanyRejectService/updateCompanyReject';
        paras = {
          'project_code' : iteminfo.project_code,
          'type' : level
        }
      } else if (type == '1' && flag == 'reject'){
          url = '/api/ac/ggc/reviewCompanyProjectService/updateLeaderDown';
          para = {
            'project_code' : iteminfo.project_code,
            'leader_message' : $scope.info.title
          }
          url1 = '/api/ac/ggc/reviewCompanyRejectService/createCompanyReject';
          paras = {
            'project_code' : iteminfo.project_code, 
            'list' : $scope.array, 
            'type' : level,
            'city_project' : iteminfo.city_project
          }
      } else if (type == '1' && flag == 'eliminate'){
          url = '/api/ac/ggc/reviewCompanyProjectService/updateLeaderBack';
          para = {
            'project_code' : iteminfo.project_code,
            'leader_message' : $scope.info.title
          }
      } else if (type == '2' && flag == 'pass'){
        url = '/api/ac/ggc/reviewCompanyProjectService/updateLeadersUp';
        para = {
          'project_code' : iteminfo.project_code,
          'leaders_message' : $scope.info.title
        }
        url1 = '/api/ac/ggc/reviewCompanyRejectService/updateCompanyReject';
        paras = {
          'project_code' : iteminfo.project_code,
          'type' : level
        }
      } else if (type == '2' && flag == 'reject'){
          url = '/api/ac/ggc/reviewCompanyProjectService/updateLeadersDown';
          para = {
            'project_code' : iteminfo.project_code,
            'leaders_message' : $scope.info.title
          }
          url1 = '/api/ac/ggc/reviewCompanyRejectService/createCompanyReject';
          paras = {
            'project_code' : iteminfo.project_code, 
            'list' : $scope.array, 
            'type' : level,
            'city_project' : iteminfo.city_project
          }
      } else if (type == '2' && flag == 'eliminate'){
          url = '/api/ac/ggc/reviewCompanyProjectService/updateLeadersBack';
          para = {
            'project_code' : iteminfo.project_code,
            'leaders_message' : $scope.info.title
          }
      } 
      if (confirm('是否认定该审核状态,一经提交,无法更改!!!')){
        $resource(url, {}, {}).save(para, function(res){
            if(res.errcode != 0){   
                toaster.error({title:"",body:res.errmsg});
                return;
            }
            console.log(res);
            toaster.success({title:"",body:'操作成功'});
            $modalInstance.close();
        });
        // 通过 or 驳回
        $resource(url1, {}, {}).save(paras, function(res){			              
            if(res.errcode === 0 || res.errcode === 10003){
                console.log(res);
                $modalInstance.close();
            }else{
                alert(res.errmsg);
            }
        });
        
      }
    }
}  